// 是否开票
export const INVOICESTATUS_TAB = [
  {
    value: '1',
    label: '待开票'
  },
  {
    value: '2',
    label: '已开票'
  }
]

// 开票笔数
export const INVOICE_MAKETYPE = [
  {
    value: '1',
    name: '单笔销售单开票'
  },
  {
    value: '2',
    name: '多笔销售单合并开票'
  }
]

export const columns = ctx => {
  return [
    {
      hide: ctx.searchForm.status === '1',
      headCheck: '1',
      prop: 'recycle',
      label: '发票状态',
      render: (h, row) => {
        const style =
          row.isRecycle === '1'
            ? 'success'
            : row.isRecycle === '2'
              ? 'danger'
              : ''
        return (
          <el-tag size="mini" type={style}>
            {row.recycleName}
          </el-tag>
        )
      }
    },
    {
      prop: 'saleOrderNo',
      label: '销售单号',
      headCheck: '1',
      width: 250,
      render: (h, row) => {
        return (
          <el-button
            type="text"
            onClick={() => {
              ctx.onExtendShow(row.saleId, 'sale')
            }}
          >
            {row.saleOrderNo}
          </el-button>
        )
      }
    },
    {
      prop: 'customerName',
      label: '关联客户',
      headCheck: '1',
      render: (h, row) => {
        return (
          <el-button
            type="text"
            onClick={() => {
              ctx.onExtendShow(row.customerId, 'customer')
            }}
          >
            {row.customerName}
          </el-button>
        )
      }
    },
    {
      prop: 'invoiceTypeName',
      headCheck: '1',
      label: '发票类型'
    },
    {
      hide: ctx.searchForm.status === '1',
      prop: 'amount',
      headCheck: ctx.searchForm.status === '2' ? '1' : '',
      label: '开票金额 （元）'
    },
    {
      hide: ctx.searchForm.status === '1',
      prop: 'operator',
      headCheck: ctx.searchForm.status === '2' ? '1' : '',
      label: '开票人员'
    },
    {
      prop: 'invoiceMain',
      label: '开票主体',
      headCheck: '1',
      hide: ctx.searchForm.status === '1'
    },
    {
      prop: 'applyTime',
      headCheck: '1',
      label: '申请时间',
      hide: ctx.searchForm.status === '2'
    },
    {
      prop: 'updateTime',
      headCheck: '1',
      label: '录入时间',
      hide: ctx.searchForm.status === '1'
    },
    {
      prop: 'saleName',
      headCheck: '1',
      label: '归属业务员'
    },
    {
      button: true,
      label: '操作',
      headFixed: '1',
      fixed: 'right',
      width: 220,
      render: (h, row) => {
        const recovery = (
          <el-button
            type="text"
            size="mini"
            onClick={() => {
              ctx.onRecovery(row)
            }}
          >
            回收
          </el-button>
        )
        const edit = (
          <el-button
            type="text"
            size="mini"
            onClick={() => {
              ctx.onEdit(row)
            }}
          >
            编辑
          </el-button>
        )
        const write = (
          <el-button
            type="text"
            size="mini"
            onClick={() => {
              ctx.onWrite(row)
            }}
          >
            录入
          </el-button>
        )

        const del = (
          <el-button
            type="text"
            size="mini"
            onClick={() => {
              ctx.onDel(row)
            }}
          >
            删除
          </el-button>
        )
        const detail = (
          <el-button
            type="text"
            size="mini"
            onClick={() => {
              ctx.onDetail(row)
            }}
          >
            详情
          </el-button>
        )
        // 开票状态   1 待开票   2 已开票
        // 发票状态是否回收  0 否 1 是
        return ctx.searchForm.status === '1'
          ? [write, del]
          : row.isRecycle === '1'
            ? [recovery, del, detail]
            : [detail]
      }
    }
  ]
}
